package com.ruihu.admin.module.business.tasknode.domain.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.ruihu.admin.common.domain.BaseEntity;
import com.ruihu.admin.module.business.tasknode.domain.dto.NodeDefectRelationAddDTO;
import com.ruihu.admin.module.business.tasknode.domain.dto.NodeDefectRelationUpdateDTO;
import lombok.Data;
import java.util.Objects;

/**
 * [  ]
 *
 * @author Tony
 * @version 1.0
 * @company 瑞虎（南京）信息技术有限公司
 * @copyright (c)  瑞虎（南京）信息技术有限公司Inc. All rights reserved.
 * @date 2022-09-22 20:56:54
 * @since JDK1.8
 */

@Data
@TableName("t_node_defect_relation")
public class NodeDefectRelationEntity extends BaseEntity {


    /**
     * defect_type_id
     */
    private Long defectTypeId;

    /**
     * task_node_id
     */
    private Long taskNodeId;

    private Long createBy;

    private Long updateBy;



    public static NodeDefectRelationEntity convertToNodeDefectRelationEntity(NodeDefectRelationAddDTO addDTO) {
        if (addDTO == null) {
            return null;
        }

        NodeDefectRelationEntity entity = new NodeDefectRelationEntity();
        entity.setDefectTypeId(addDTO.getDefectTypeId());
        entity.setTaskNodeId(addDTO.getTaskNodeId());
        return entity;
    }


    public static NodeDefectRelationEntity convertToNodeDefectRelationEntity(NodeDefectRelationUpdateDTO updateDTO) {
        if (updateDTO == null) {
           return null;
        }

        NodeDefectRelationEntity entity = new NodeDefectRelationEntity();
        entity.setId(updateDTO.getId());
        entity.setDefectTypeId(updateDTO.getDefectTypeId());
        entity.setTaskNodeId(updateDTO.getTaskNodeId());
        return entity;
    }

    public static NodeDefectRelationEntity copyIgnoreNullAndEmpty(NodeDefectRelationEntity sourceEntity, NodeDefectRelationEntity destEntity) {
        if (Objects.isNull(sourceEntity))
            return destEntity;
        if (Objects.nonNull(sourceEntity.getId())) {
           destEntity.setId(sourceEntity.getId());
        }
        if (Objects.nonNull(sourceEntity.getDefectTypeId())) {
           destEntity.setDefectTypeId(sourceEntity.getDefectTypeId());
        }
        if (Objects.nonNull(sourceEntity.getTaskNodeId())) {
           destEntity.setTaskNodeId(sourceEntity.getTaskNodeId());
        }
        if (Objects.nonNull(sourceEntity.getCreateTime())) {
           destEntity.setCreateTime(sourceEntity.getCreateTime());
        }
        if (Objects.nonNull(sourceEntity.getUpdateTime())) {
           destEntity.setUpdateTime(sourceEntity.getUpdateTime());
        }
        return destEntity;
    }
}
